-
Notifications
You must be signed in to change notification settings - Fork 381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat rn picker-view #1760
base: master
Are you sure you want to change the base?
Feat rn picker-view #1760
Conversation
itemWidth, | ||
textStyleFromParent, | ||
textStyle, | ||
hasVarDec, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个不用传递下来啊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
理论上这玩意不需要接收样式吧
itemHeight, | ||
itemWidth = '100%', | ||
textStyleFromParent, | ||
textStyle, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这些style走context传递下来就可以了吧,不用props层层透传
|
||
interface ColumnProps { | ||
children?: React.ReactNode | ||
columnData: React.ReactNode[] | ||
columnStyle: Record<string, any> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这又是啥
const visibleCount = 5 | ||
|
||
const _PickerViewColumn = forwardRef<HandlerRef<ScrollView & View, ColumnProps>, ColumnProps>((props: ColumnProps, ref) => { | ||
const { | ||
columnData, | ||
columnIndex, | ||
columnStyle, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为啥有这么多style,都是干嘛用的
) | ||
|
||
return ( | ||
<SafeAreaView style={[{ display: 'flex', flex: 1 }]}> | ||
<SafeAreaView style={[styles.wrapper, normalStyle]}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为啥需要包safeAreaView
const renderMask = () => ( | ||
<PickerMask | ||
itemHeight={itemHeight} | ||
maskContainerStyle={pickerMaskStyle} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overlay改为indicator
return index * itemRawH | ||
}, [itemRawH]) | ||
|
||
const stableResetScrollPosition = useStableCallback((y: number) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个useStableCb是干嘛用的
const paddingHeight = useMemo( | ||
() => Math.round((pickerH - itemHeight) / 2), | ||
[pickerH, itemHeight] | ||
) | ||
|
||
const snapToOffsets = useMemo( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
无效的useMemo
onMomentumScrollEnd({ nativeEvent: { contentOffset: { y } } }) | ||
} | ||
}) | ||
const debounceResetScrollPosition = useDebounceCallback(stableResetScrollPosition, 10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10ms能有效果么?感觉不用debounce,维护一个状态标记已经进行过reset就行了吧
* ✘ indicator-class | ||
* ✘ mask-style | ||
* ✔ mask-style |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mask-class和indicator-class需要编译支持一下,参考hover-class
const indicatorStyle = parseInlineStyle(props['indicator-style']) | ||
const pickerMaskStyle = parseInlineStyle(props['mask-style']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不需要在这里单独parse,都应该走统一的getStyle
No description provided.